package com.example.administrator.wallet.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.wallet.R;
import com.example.administrator.wallet.model.bean.MainBean;
import com.example.administrator.wallet.view.activity.finds.kkbank.TransactionRecordsActivity;

import java.util.List;

/**
 * Effect:
 * <p>
 * Author:  CaiYapeng
 * <p>
 * Time  :  2018/7/10.
 */
//成交记录   item_transaction_records     TransactionRecordsActivity
public class TransactionRecordsAdapter extends BaseAdapter {
    private Activity context;
    private List<MainBean.DataBean.ListBean> datas;
    private OnClick click;

    public TransactionRecordsAdapter(TransactionRecordsActivity activity, List<MainBean.DataBean.ListBean> dataBeanList) {
        this.context = activity;
        this.datas = dataBeanList;
    }

    @Override
    public int getCount() {
        return datas == null ? 0 : datas.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            holder = new ViewHolder();
            view = View.inflate(context, R.layout.item_transaction_records, null);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tv_Volume = (TextView) view.findViewById(R.id.tv_Volume);//成交额
        holder.tv_Transactions_Number = (TextView) view.findViewById(R.id.tv_Transactions_Number);//成交数量
        holder.tv_Transaction_Price = (TextView) view.findViewById(R.id.tv_Transaction_Price);//成交价格
        holder.tv_data = (TextView) view.findViewById(R.id.tv_data);//日期
        holder.tv_buy = (TextView) view.findViewById(R.id.tv_buy);//买入卖出
        holder.tv_buy_color = (TextView) view.findViewById(R.id.tv_buy_color);//颜色


        holder.tv_Volume.setText(datas.get(i).getCoin_symbol());
        holder.tv_Transactions_Number.setText(datas.get(i).getBalance());
        holder.tv_Transaction_Price.setText("≈￥" + datas.get(i).getMoney());
        holder.tv_data.setText("≈￥" + datas.get(i).getMoney());
        holder.tv_buy.setText("≈￥" + datas.get(i).getMoney());
        holder.tv_buy_color.setText("≈￥" + datas.get(i).getMoney());

        return view;
    }

    public class ViewHolder {
        private TextView tv_Volume;
        private TextView tv_Transactions_Number;
        private TextView tv_Transaction_Price;
        private TextView tv_data;
        private TextView tv_buy;
        private TextView tv_buy_color;

    }

    public interface OnClick {
        void Click(MainBean.DataBean.ListBean dataBean);
    }

    public void getClickPst(OnClick click) {
        this.click = click;
    }
}
